<template>
  <h1>猜数字练习</h1>
  <input type="text" v-model="num" placeholder="请输入您猜的数字">
  <button @click="guess">猜一猜</button>
  <h3>小提示：<span>{{hint}}</span></h3>
</template>


<script setup>
  import { ref } from 'vue';
  let n = parseInt(Math.random() * 100)+1;
  console.log(n);
  const num = ref('');
  const hint = ref('');

  const guess = () => {
    parseInt(num.value);
    if(num.value>n){
      hint.value = '猜大了';
    }else if(num.value<n){
      hint.value = '猜小了';
    }else{
      hint.value = '恭喜您，猜对了';
    }

  }
</script>

<style scoped>

</style>